package org.dxy.app.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @description: Web MVC配置，包含CORS配置
 * @author: Administrator
 * @createTime: 2025/5/3 19:06
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins(
                        "http://localhost:8848",
                        "http://localhost:63342", // 线程池端口
                        "http://127.0.0.1:8848"  // 前端地址
                )
                .allowCredentials(true)
                .allowedMethods("*")
                .allowedHeaders("*")
                .exposedHeaders("Authorization", "X-Auth-Token")
                .maxAge(3600);
    }

}
